﻿module UriTests

open System.IO
open NUnit.Framework
open UriParsing
open Uris

[<TestFixture>]
type testUriParsing() =

    [<Test>]
    member self.testParse() =
        let uri = parseUrl "http://example.com/" None
        Assert.AreEqual("http", uri.scheme)
        Assert.AreEqual("example.com", uri.host)
        Assert.AreEqual("/", uri.path)
        Assert.AreEqual("http://example.com/", uri.toUrl())

    [<Test>]
    member self.testParse2() =
        let uri = parseUrl "http://example.com/domains/reserved" None
        Assert.AreEqual("example.com", uri.host)
        Assert.AreEqual("http://example.com/domains/reserved", uri.toUrl())

    [<Test>]
    member self.testParseRel() =
        let refUri = {scheme="http";host="example.com";port=None; path="/domains/example";queryString="";fragment=""}
        let uri = parseUrl "/domains/reserved" (Some refUri)
        Assert.AreEqual("example.com", uri.host)
        Assert.AreEqual("http://example.com/domains/reserved", uri.toUrl())